﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DAL;
using QLCongNo.XuatHangform;
using DevExpress.XtraGrid;
namespace QLCongNo
{
    public partial class DSPhieuXuat : UserControl
    {
        NhapXuatDAL px = new NhapXuatDAL();
        public DSPhieuXuat()
        {
            InitializeComponent();
            
        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {
            
            double tongtien;
            TauDAL tau = new TauDAL();
            cbTau.DataSource = tau.DSTau();
            cbTau.DisplayMember = "SoTau";
            cbTau.ValueMember = "SoTau";
            
            
            DataTable dsPhieuXuat = new DataTable();
            dsPhieuXuat = px.DSPhieuXuat();
            //loadGridView(dsPhieuXuat);
            dgvPhieuXuat.DataSource = dsPhieuXuat;
            tongtien = 0;
            for (int i = 0; i < dsPhieuXuat.Rows.Count; i++)
            {
                tongtien = tongtien + Convert.ToDouble(dsPhieuXuat.Rows[i][5]);
            }
            lbTongtien.Text = tongtien.ToString("#,###");
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            XuatHang form = new XuatHang();
            form.Show();
        }

        private void dgvPhieuXuat_Click(object sender, EventArgs e)
        {

        }

        /*public void loadGridView(DataTable ds)
        {

            dgvPhieuXuat.DataSource = ds;
            dgvPhieuXuat.Columns[0].Width = 150;
            dgvPhieuXuat.Columns[1].Width = 200;
            dgvPhieuXuat.Columns[2].Width = 200;
            dgvPhieuXuat.Columns[3].Width = 200;
        }
        */
        private void cbTau_SelectedIndexChanged(object sender, EventArgs e)
        {
            string matau;
            double tongtien;
            matau = cbTau.SelectedValue.ToString();
            DataTable dsPhieuXuat = new DataTable();
            dsPhieuXuat = px.LocTheoTau(matau);
            dgvPhieuXuat.DataSource = dsPhieuXuat;
            //loadGridView(dsPhieuXuat);
            tongtien = 0;
            for (int i = 0; i < dsPhieuXuat.Rows.Count; i++)
            {
                tongtien = tongtien + Convert.ToDouble(dsPhieuXuat.Rows[i][5]);
            }
            lbTongtien.Text = tongtien.ToString("#,###");
        }


        private void dgvPhieuXuat_MouseClick(object sender, MouseEventArgs e)
        {
         
        }


        

    }
}
